home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / schnlsp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  15.8 KB  |  531 lines

  1. //+---------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //  Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. //  File:       schnlsp.h
  7. //
  8. //  Contents:   Public Definitions for SCHANNEL Security Provider
  9. //
  10. //  Classes:
  11. //
  12. //  Functions:
  13. //
  14. //  History:    6-8-96   Created
  15. //
  16. //----------------------------------------------------------------------------
  17.  
  18. #ifndef __SCHNLSP_H__
  19. #define __SCHNLSP_H__
  20. #pragma option push -b
  21.  
  22. #include <wincrypt.h>
  23.  
  24.  
  25. #define UNISP_NAME_A    "Microsoft Unified Security Protocol Provider"
  26. #define UNISP_NAME_W    L"Microsoft Unified Security Protocol Provider"
  27.  
  28. #define SSL2SP_NAME_A    "Microsoft SSL 2.0"
  29. #define SSL2SP_NAME_W    L"Microsoft SSL 2.0"
  30.  
  31. #define SSL3SP_NAME_A    "Microsoft SSL 3.0"
  32. #define SSL3SP_NAME_W    L"Microsoft SSL 3.0"
  33.  
  34. #define TLS1SP_NAME_A    "Microsoft TLS 1.0"
  35. #define TLS1SP_NAME_W    L"Microsoft TLS 1.0"
  36.  
  37. #define PCT1SP_NAME_A    "Microsoft PCT 1.0"
  38. #define PCT1SP_NAME_W    L"Microsoft PCT 1.0"
  39.  
  40.  
  41. #ifdef UNICODE
  42.  
  43. #define UNISP_NAME  UNISP_NAME_W
  44. #define PCT1SP_NAME  PCT1SP_NAME_W
  45. #define SSL2SP_NAME  SSL2SP_NAME_W
  46. #define SSL3SP_NAME  SSL3SP_NAME_W
  47. #define TLS1SP_NAME  TLS1SP_NAME_W
  48.  
  49. #else
  50.  
  51. #define UNISP_NAME  UNISP_NAME_A
  52. #define PCT1SP_NAME  PCT1SP_NAME_A
  53. #define SSL2SP_NAME  SSL2SP_NAME_A
  54. #define SSL3SP_NAME  SSL3SP_NAME_A
  55. #define TLS1SP_NAME  TLS1SP_NAME_A
  56.  
  57. #endif
  58.  
  59. #define SSL2SP_RPC_ID    12
  60. #define PCT1SP_RPC_ID    13
  61. #define SSL3SP_RPC_ID    14
  62. #define UNISP_RPC_ID     15
  63. #define TLS1SP_RPC_ID    16
  64.  
  65.  
  66.  
  67. #define SCH_CRED_V1              0x00000001
  68. #define SCH_CRED_V2              0x00000002  // for legacy code
  69. #define SCH_CRED_VERSION         0x00000002  // for legacy code
  70. #define SCHANNEL_CRED_VERSION    0x00000003
  71.  
  72.  
  73.  
  74.  
  75. //
  76. // QueryContextAttributes/QueryCredentialsAttribute extensions
  77. //
  78. #define SECPKG_ATTR_REMOTE_CERT_CONTEXT  0x53  // returns PCCERT_CONTEXT
  79. #define SECPKG_ATTR_LOCAL_CERT_CONTEXT   0x54  // returns PCCERT_CONTEXT
  80. #define SECPKG_ATTR_ROOT_STORE           0x55  // returns HCERTCONTEXT to the root store
  81. #define SECPKG_ATTR_SUPPORTED_ALGS       0x56  // returns SecPkgCred_SupportedAlgs
  82. #define SECPKG_ATTR_CIPHER_STRENGTHS     0x57  // returns SecPkgCred_CipherStrengths
  83. #define SECPKG_ATTR_SUPPORTED_PROTOCOLS  0x58  // returns SecPkgCred_SupportedProtocols
  84. #define SECPKG_ATTR_ISSUER_LIST_EX       0x59  // returns SecPkgContext_IssuerListInfoEx
  85. #define SECPKG_ATTR_CONNECTION_INFO      0x5a  // returns SecPkgContext_ConnectionInfo
  86.  
  87.  
  88.  
  89. typedef struct _SecPkgCred_SupportedAlgs
  90. {
  91.     DWORD        cSupportedAlgs;
  92.     ALG_ID        *palgSupportedAlgs;
  93. } SecPkgCred_SupportedAlgs, *PSecPkgCred_SupportedAlgs;
  94.  
  95. typedef struct _SecPkgCred_CipherStrengths
  96. {
  97.     DWORD       dwMinimumCipherStrength;
  98.     DWORD       dwMaximumCipherStrength;
  99. } SecPkgCred_CipherStrengths, *PSecPkgCred_CipherStrengths;
  100.  
  101. typedef struct _SecPkgCred_SupportedProtocols
  102. {
  103.     DWORD          grbitProtocol;
  104. } SecPkgCred_SupportedProtocols, *PSecPkgCred_SupportedProtocols;
  105.  
  106. typedef struct _SecPkgContext_IssuerListInfoEx
  107. {
  108.     PCERT_NAME_BLOB       aIssuers;
  109.     DWORD               cIssuers;
  110. } SecPkgContext_IssuerListInfoEx, *PSecPkgContext_IssuerListInfoEx;
  111.  
  112. typedef struct _SecPkgContext_ConnectionInfo
  113. {
  114.     DWORD    dwProtocol;
  115.     ALG_ID   aiCipher;
  116.     DWORD    dwCipherStrength;
  117.     ALG_ID   aiHash;
  118.     DWORD    dwHashStrength;
  119.     ALG_ID   aiExch;
  120.     DWORD    dwExchStrength;
  121. }SecPkgContext_ConnectionInfo, *PSecPkgContext_ConnectionInfo;
  122.  
  123.  
  124. //
  125. // SCHANNEL Credentials data structure
  126. //
  127. struct _HMAPPER;
  128.  
  129. typedef struct _SCHANNEL_CRED
  130. {
  131.     DWORD           dwVersion;
  132.     DWORD           cCreds;
  133.     PCCERT_CONTEXT  *paCred; 
  134.     HCERTSTORE      hRootStore;
  135.  
  136.     DWORD            cMappers;                
  137.     struct _HMAPPER  **aphMappers;     
  138.  
  139.     DWORD           cSupportedAlgs;
  140.     ALG_ID          *palgSupportedAlgs;
  141.  
  142.     DWORD           grbitEnabledProtocols;
  143.     DWORD           dwMinimumCipherStrength;
  144.     DWORD           dwMaximumCipherStrength;
  145.     DWORD           dwSessionLifespan;
  146.  
  147. } SCHANNEL_CRED, *PSCHANNEL_CRED;
  148.  
  149.  
  150. // 
  151. //
  152. // ApplyControlToken PkgParams types
  153. //
  154. // These identifiers are the DWORD types
  155. // to be passed into ApplyControlToken
  156. // through a PkgParams buffer.
  157.  
  158. //
  159. // SCHANNEL_RENEGOTIATE
  160. //
  161. // Cause SCHANNEL to renegotiate 
  162. // a connection.
  163. //
  164. #define SCHANNEL_RENEGOTIATE 0
  165.  
  166. //
  167. // SCHANNEL_SHUTDOWN
  168. //
  169. // Cause SCHANNEL to shutdown 
  170. // a connection.
  171. //
  172.  
  173. #define SCHANNEL_SHUTDOWN    1
  174.  
  175.  
  176. //
  177. //
  178. // ADDITIONAL SCHANNEL ERROR CODES
  179. //
  180. //
  181.  
  182.  
  183. //
  184. // MessageId: SEC_I_INCOMPLETE_CREDENTIALS
  185. //
  186. // MessageText:
  187. //
  188. //  If this is returned from InitializeSecurityContext, it indicates
  189. //  that the credentials supplied were incomplete, and client-auth was
  190. //  attempted.  On receipt, the client should call QueryContextAttributes
  191. //  with SECPKG_ATTR_LOCAL_CERT to get the cert that was negotiated,
  192. //  and the supply the private key with this cert to AcquireCredential
  193. //  to get a new credential.  The context should then be closed, 
  194. //  and renegotiation should be completed.
  195. //  
  196. //
  197. #define SEC_I_INCOMPLETE_CREDENTIALS      ((HRESULT)0x00090320L)
  198.  
  199. #define SEC_E_INCOMPLETE_CREDENTIALS      ((HRESULT)0x80090320L)
  200.  
  201.  
  202. //
  203. // MessageId: SEC_I_RENEGOTIATE
  204. //
  205. // MessageText:
  206. //
  207. // This is returned by UnsealMessage, and indicates that the app should
  208. // restart the renegotiation loop.  It should use the existing context, and
  209. // pass in no data in the input buffers for the first call to AcceptSecurityContext
  210. // or InitializeSecurityContext. 
  211. //
  212. #define SEC_I_RENEGOTIATE            ((HRESULT)0x00090321L)
  213.  
  214.  
  215.  
  216. //
  217. //
  218. // ADDITIONAL SCHANNEL CERTIFICATE PROPERTIES
  219. //
  220. //
  221.  
  222.  
  223. // This property specifies the DER private key data associated with this
  224. // certificate.  It is for use with legacy IIS style private keys.
  225. //
  226. // PBYTE
  227. //
  228. #define CERT_SCHANNEL_IIS_PRIVATE_KEY_PROP_ID  (CERT_FIRST_USER_PROP_ID + 0)
  229.  
  230. // The password used to crack the private key associated with the certificate.
  231. // It is for use with legacy IIS style private keys.
  232. //
  233. // PBYTE
  234. #define CERT_SCHANNEL_IIS_PASSWORD_PROP_ID  (CERT_FIRST_USER_PROP_ID + 1)
  235.  
  236. // This is the unique ID of a Server Gated Cryptography certificate associated
  237. // with this certificate.
  238. //
  239. // CRYPT_BIT_BLOB
  240. #define CERT_SCHANNEL_SGC_CERTIFICATE_PROP_ID  (CERT_FIRST_USER_PROP_ID + 2)
  241.  
  242.  
  243.  
  244. //
  245. // Flags for identifying the various different protocols.
  246. //
  247.  
  248. /* flag/identifiers for protocols we support */
  249. #define SP_PROT_PCT1_SERVER             0x00000001
  250. #define SP_PROT_PCT1_CLIENT             0x00000002
  251. #define SP_PROT_PCT1                    (SP_PROT_PCT1_SERVER | SP_PROT_PCT1_CLIENT)
  252.  
  253. #define SP_PROT_SSL2_SERVER             0x00000004
  254. #define SP_PROT_SSL2_CLIENT             0x00000008
  255. #define SP_PROT_SSL2                    (SP_PROT_SSL2_SERVER | SP_PROT_SSL2_CLIENT)
  256.  
  257. #define SP_PROT_SSL3_SERVER             0x00000010
  258. #define SP_PROT_SSL3_CLIENT             0x00000020
  259. #define SP_PROT_SSL3                    (SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT)
  260.  
  261. #define SP_PROT_TLS1_SERVER             0x00000040
  262. #define SP_PROT_TLS1_CLIENT             0x00000080
  263. #define SP_PROT_TLS1                    (SP_PROT_TLS1_SERVER | SP_PROT_TLS1_CLIENT)
  264.  
  265. #define SP_PROT_SSL3TLS1_CLIENTS        (SP_PROT_TLS1_CLIENT | SP_PROT_SSL3_CLIENT)
  266. #define SP_PROT_SSL3TLS1_SERVERS        (SP_PROT_TLS1_SERVER | SP_PROT_SSL3_SERVER)
  267. #define SP_PROT_SSL3TLS1                (SP_PROT_SSL3 | SP_PROT_TLS1)
  268.  
  269. #define SP_PROT_UNI_SERVER              0x40000000
  270. #define SP_PROT_UNI_CLIENT              0x80000000
  271. #define SP_PROT_UNI                     (SP_PROT_UNI_SERVER | SP_PROT_UNI_CLIENT)
  272.  
  273. #define SP_PROT_ALL                     0xffffffff
  274. #define SP_PROT_ALL_NOT_TLS             (SP_PROT_PCT1 | SP_PROT_SSL2 | SP_PROT_SSL3)
  275. #define SP_PROT_NONE                    0
  276. #define SP_PROT_CLIENTS                 (SP_PROT_PCT1_CLIENT | SP_PROT_SSL2_CLIENT | SP_PROT_SSL3_CLIENT | SP_PROT_UNI_CLIENT | SP_PROT_TLS1_CLIENT)
  277. #define SP_PROT_SERVERS                 (SP_PROT_PCT1_SERVER | SP_PROT_SSL2_SERVER | SP_PROT_SSL3_SERVER | SP_PROT_UNI_SERVER | SP_PROT_TLS1_SERVER)
  278.  
  279.  
  280. // A call for IIS to empty the cache.
  281.  
  282. BOOL
  283. SslEmptyCache(VOID);
  284.  
  285. //
  286. //
  287. //  Support for legacy applications
  288. //  NOTE: Do not use the following 
  289. //  API's and structures for new code.
  290. //
  291.  
  292.  
  293. #define SSLOLD_NAME_A    "Microsoft SSL"
  294. #define SSLOLD_NAME_W    L"Microsoft SSL"
  295. #define PCTOLD_NAME_A    "Microsoft PCT"
  296. #define PCTOLD_NAME_W    L"Microsoft PCT"
  297.  
  298. #ifdef UNICODE
  299. #define SSLOLD_NAME SSLOLD_NAME_W
  300. #define PCTOLD_NAME PCTOLD_NAME_W
  301. #else
  302. #define SSLOLD_NAME SSLOLD_NAME_A
  303. #define PCTOLD_NAME PCTOLD_NAME_A
  304. #endif
  305.  
  306. #define NETWORK_DREP    0x00000000
  307.  
  308.  
  309.  
  310. // Structures for compatability with the
  311. // NT 4.0 SP2 / IE 3.0 schannel interface, do
  312. // not use.
  313.  
  314. typedef struct _SSL_CREDENTIAL_CERTIFICATE {
  315.     DWORD   cbPrivateKey;
  316.     PBYTE   pPrivateKey;
  317.     DWORD   cbCertificate;
  318.     PBYTE   pCertificate;
  319.     PSTR    pszPassword;
  320. } SSL_CREDENTIAL_CERTIFICATE, * PSSL_CREDENTIAL_CERTIFICATE;
  321.  
  322.  
  323.  
  324.  
  325. // Structures for use with the 
  326. // NT 4.0 SP3 Schannel interface, 
  327. // do not use.
  328. #define SCHANNEL_SECRET_TYPE_CAPI       0x00000001
  329. #define SCHANNEL_SECRET_PRIVKEY         0x00000002
  330. #define SCH_CRED_X509_CERTCHAIN   0x00000001
  331. #define SCH_CRED_X509_CAPI        0x00000002
  332. #define SCH_CRED_CERT_CONTEXT     0x00000003
  333.  
  334. struct _HMAPPER;
  335. typedef struct _SCH_CRED
  336. {
  337.     DWORD     dwVersion;                // always SCH_CRED_VERSION.
  338.     DWORD     cCreds;                   // Number of credentials.
  339.     PVOID     *paSecret;                // Array of SCH_CRED_SECRET_* pointers
  340.     PVOID     *paPublic;                // Array of SCH_CRED_PUBLIC_* pointers
  341.     DWORD     cMappers;                 // Number of credential mappers.
  342.     struct _HMAPPER   **aphMappers;     // pointer to an array of pointers to credential mappers 
  343. } SCH_CRED, * PSCH_CRED;
  344.  
  345. // Structures for use with the 
  346. // NT 4.0 SP3 Schannel interface, 
  347. // do not use.
  348. typedef struct _SCH_CRED_SECRET_CAPI
  349. {
  350.     DWORD           dwType;      // SCHANNEL_SECRET_TYPE_CAPI
  351.     HCRYPTPROV      hProv;       // credential secret information.
  352.  
  353. } SCH_CRED_SECRET_CAPI, * PSCH_CRED_SECRET_CAPI;
  354.  
  355.  
  356. // Structures for use with the 
  357. // NT 4.0 SP3 Schannel interface, 
  358. // do not use.
  359. typedef struct _SCH_CRED_SECRET_PRIVKEY
  360. {
  361.     DWORD           dwType;       // SCHANNEL_SECRET_PRIVKEY
  362.     PBYTE           pPrivateKey;   // Der encoded private key
  363.     DWORD           cbPrivateKey;
  364.     PSTR            pszPassword;  // Password to crack the private key.
  365.  
  366. } SCH_CRED_SECRET_PRIVKEY, * PSCH_CRED_SECRET_PRIVKEY;
  367.  
  368.  
  369. // Structures for use with the 
  370. // NT 4.0 SP3 Schannel interface, 
  371. // do not use.
  372. typedef struct _SCH_CRED_PUBLIC_CERTCHAIN
  373. {
  374.     DWORD       dwType;
  375.     DWORD       cbCertChain;
  376.     PBYTE       pCertChain;
  377. } SCH_CRED_PUBLIC_CERTCHAIN, *PSCH_CRED_PUBLIC_CERTCHAIN;
  378.  
  379. // Structures for use with the 
  380. // NT 4.0 SP3 Schannel interface, 
  381. // do not use.
  382. typedef struct _SCH_CRED_PUBLIC_CAPI
  383. {
  384.     DWORD           dwType;      // SCH_CRED_X509_CAPI
  385.     HCRYPTPROV      hProv;       // CryptoAPI handle (usually a token CSP)
  386.  
  387. } SCH_CRED_PUBLIC_CAPI, * PSCH_CRED_PUBLIC_CAPI;
  388.  
  389. // Attributes for getting NON CAPI2 
  390. // certificate blobs.  Use the CAPI2
  391. // attributes defined above instead.
  392. #define SECPKG_ATTR_ISSUER_LIST          0x50  // SecPkgContext_IssuerListInfo
  393. #define SECPKG_ATTR_REMOTE_CRED          0x51  // SecPkgContext_RemoteCredentialInfo
  394. #define SECPKG_ATTR_LOCAL_CRED           0x52  // SecPkgContext_LocalCredentialInfo
  395.  
  396. // Attributes for getting NON CAPI2 
  397. // certificate blobs.  Use the CAPI2
  398. // attributes defined above instead.
  399. typedef struct _SecPkgContext_IssuerListInfo
  400. {
  401.     DWORD   cbIssuerList;
  402.     PBYTE   pIssuerList;
  403. } SecPkgContext_IssuerListInfo, *PSecPkgContext_IssuerListInfo;
  404.  
  405. // Attributes for getting NON CAPI2 
  406. // certificate blobs.  Use the CAPI2
  407. // attributes defined above instead.
  408. typedef struct _SecPkgContext_RemoteCredentialInfo
  409. {
  410.     DWORD   cbCertificateChain;     // count of bytes in cert chain buffer.
  411.     PBYTE   pbCertificateChain;     // DER encoded chain of certificates, leaf cert first.
  412.     DWORD   cCertificates;
  413.     DWORD   fFlags;
  414.     DWORD   dwBits;                 // Number of bits in the remote credentials
  415. } SecPkgContext_RemoteCredentialInfo, *PSecPkgContext_RemoteCredentialInfo;
  416.  
  417. // Make the old spelling error compatable
  418. typedef SecPkgContext_RemoteCredentialInfo SecPkgContext_RemoteCredenitalInfo, *PSecPkgContext_RemoteCredenitalInfo;
  419.  
  420. // Attributes for getting NON CAPI2 
  421. // certificate blobs.  Use the CAPI2
  422. // attributes defined above instead.
  423. typedef struct _SecPkgContext_LocalCredentialInfo
  424. {
  425.     DWORD   cbCertificateChain;     // count of bytes in cert chain buffer.
  426.     PBYTE   pbCertificateChain;     // DER encoded chain of certificates, leaf cert first.
  427.     DWORD   cCertificates;
  428.     DWORD   fFlags;
  429.     DWORD   dwBits;                 // Number of bits in the remote credentials.
  430. } SecPkgContext_LocalCredentialInfo, *PSecPkgContext_LocalCredentialInfo;
  431.  
  432. // Make the old spelling error compatable.
  433. typedef SecPkgContext_LocalCredentialInfo SecPkgContext_LocalCredenitalInfo, *PSecPkgContext_LocalCredenitalInfo;
  434. #define RCRED_STATUS_NOCRED          0x00000000
  435. #define RCRED_CRED_EXISTS            0x00000001
  436. #define RCRED_STATUS_UNKNOWN_ISSUER  0x00000002    // The last cert in this chain has 
  437.                                                    // an issuer that is unknown to us.
  438. #define LCRED_STATUS_NOCRED          0x00000000
  439. #define LCRED_CRED_EXISTS            0x00000001
  440. #define LCRED_STATUS_UNKNOWN_ISSUER  0x00000002    // The last cert in this chain has 
  441.  
  442.  
  443. // Structures needed for Pre NT4.0 SP2 calls.
  444. typedef struct _PctPublicKey
  445. {
  446.     DWORD Type;
  447.     DWORD cbKey;
  448.     UCHAR pKey[1];
  449. } PctPublicKey;
  450.  
  451. typedef struct _X509Certificate {
  452.     DWORD           Version;
  453.     DWORD           SerialNumber[4];
  454.     ALG_ID          SignatureAlgorithm;
  455.     FILETIME        ValidFrom;
  456.     FILETIME        ValidUntil;
  457.     PSTR            pszIssuer;
  458.     PSTR            pszSubject;
  459.     PctPublicKey    *pPublicKey;
  460. } X509Certificate, * PX509Certificate;
  461.  
  462.  
  463.  
  464. // Pre NT4.0 SP2 calls.  Call CAPI1 or CAPI2
  465. // to get the same functionality instead.
  466. BOOL
  467. SslGenerateKeyPair(
  468.     PSSL_CREDENTIAL_CERTIFICATE pCerts,
  469.     PSTR pszDN,
  470.     PSTR pszPassword,
  471.     DWORD Bits );
  472.  
  473. // Pre NT4.0 SP2 calls.  Call CAPI1 or CAPI2
  474. // to get the same functionality instead.
  475. VOID
  476. SslGenerateRandomBits(
  477.     PUCHAR      pRandomData,
  478.     LONG        cRandomData
  479.     );
  480.  
  481. // Pre NT4.0 SP2 calls.  Call CAPI1 or CAPI2
  482. // to get the same functionality instead.
  483. BOOL
  484. SslCrackCertificate(
  485.     PUCHAR              pbCertificate,
  486.     DWORD               cbCertificate,
  487.     DWORD               dwFlags,
  488.     PX509Certificate *  ppCertificate
  489.     );
  490.  
  491. // Pre NT4.0 SP2 calls.  Call CAPI1 or CAPI2
  492. // to get the same functionality instead.
  493. VOID
  494. SslFreeCertificate(
  495.     PX509Certificate    pCertificate
  496.     );
  497.  
  498. // Call QueryCredentialsAttribute instead.
  499. BOOL
  500. SslGetDefaultIssuers(
  501.     PBYTE pbIssuers,
  502.     DWORD *pcbIssuers);
  503.  
  504.  
  505. #define SSL_CRACK_CERTIFICATE_NAME  TEXT("SslCrackCertificate")
  506. #define SSL_FREE_CERTIFICATE_NAME   TEXT("SslFreeCertificate")
  507.  
  508. // Pre NT4.0 SP2 calls.  Call CAPI1 or CAPI2
  509. // to get the same functionality instead.
  510. typedef BOOL
  511. (WINAPI * SSL_CRACK_CERTIFICATE_FN)
  512. (
  513.     PUCHAR              pbCertificate,
  514.     DWORD               cbCertificate,
  515.     BOOL                VerifySignature,
  516.     PX509Certificate *  ppCertificate
  517. );
  518.  
  519.  
  520. // Pre NT4.0 SP2 calls.  Call CAPI1 or CAPI2
  521. // to get the same functionality instead.
  522. typedef VOID
  523. (WINAPI * SSL_FREE_CERTIFICATE_FN)
  524. (
  525.     PX509Certificate    pCertificate
  526. );
  527.  
  528.  
  529. #pragma option pop
  530. #endif //__SCHNLSP_H__
  531.